package com.mls.fivedistrict.controller.backend;

import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.server.ReportService;
import com.mls.fivedistrict.server.UserAuthService;
import com.mls.fivedistrict.server.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by nanji on 2018/3/21.
 */
@RestController
@RequestMapping("/api/manager")
public class ReportController extends BaseController {
    @Resource(name = "userService")
    UserService userService;
    @Resource(name = "reportService")
    ReportService reportService;
    @Resource(name = "userAuthService")
    UserAuthService userAuthService;

    /**
     * 获取用户总量
     *
     * @return
     */
    @PostMapping(path = "/v1/report/userTotal")
    public ServiceResponse getUserTotal() {
        return userService.getUserTotal();
    }

    @PostMapping(path = "/v1/report/todayActivityPersonCount")
    public ServiceResponse getActivityPersonSum() {
//        last_activity_date
        Long count = userService.getTodayActivityPersonCount();
        return ServiceResponse.createSuccessResponse(count);
    }

    /**
     * 获取用户激活总量
     *
     * @return
     */
    @PostMapping(path = "/v1/report/userActivateTotal")
    public ServiceResponse getUserActivateTotal() {
        return userAuthService.getUserActivateTotal();
    }

    /**
     * 获取用户未激活总量
     *
     * @return
     */
    @PostMapping(path = "/v1/report/userUnactivateTotal")
    public ServiceResponse getUserUnactivateTotal() {
        return userAuthService.getUserUnactivateTotal();
    }

    /**
     * 获取绑定国盾区用户数量
     *
     * @return
     */
    @PostMapping(path = "/v1/report/userBindSum")
    public ServiceResponse getUserBindSum() {
        return userService.getUserBindSum();
    }

    /**
     * 获取算力总量
     *
     * @return
     */
    @PostMapping(path = "/v1/report/calculateSum")
    public ServiceResponse getCalculateSum() {
        return userService.getCalculateSum();
    }

    /**
     * 获取DWQ积分已经挖掘的数目
     *
     * @return
     */
    @PostMapping(path = "/v1/report/dwqMineSum")
    public ServiceResponse getDwqMineSum() {
        return reportService.getDwqMineSum();
    }

    /**
     * 获取用户的注册报表信息
     *
     * @return
     */
    @GetMapping("/v1/userReports")
    public ServiceResponse getTotalEveryDay() {
        return reportService.TotalEveryDay(getPageFilter());
    }

    /**
     * 获取用户的积分报表
     *
     * @return
     */
    @RequestMapping("/v1/report/userIntegralReports")
    public ServiceResponse getUserIntegralReports() {
        return reportService.getUserIntegralReports(getPageFilter());
    }


    /**
     * 根据搜索条件
     * 获取用户的积分汇总，计算积分的总和
     *
     * @return
     */
    @RequestMapping("/v1/report/sumUserIntegralReports")
    public ServiceResponse getSumUserIntegralReports() {
        return reportService.getSumUserIntegralReports(getPageFilter());
    }


    /**
     * 获取用户积分提取报表
     *
     * @return
     */
    @RequestMapping("/v1/report/userIntegralExtractReports")
    public ServiceResponse getUserIntegralExtractReports() {
        return reportService.getUserIntegralExtractReports(getPageFilter());
    }

    /**
     * 获取用户积分提取报表总量
     *
     * @return
     */
    @RequestMapping("/v1/report/sumUserIntegralExtractReports")
    public ServiceResponse getSumUserIntegralExtractReports() {
        return reportService.getSumUserIntegralExtractReports(getPageFilter());
    }

    /**
     * 用户算力报表列表接口，并提供搜索功能
     *
     * @return
     */
    @RequestMapping("/v1/report/userCalculateReports")
    public ServiceResponse getUserCalculateReports() {
        return reportService.getUserCalculateReports(getPageFilter());
    }

    /**
     * 根据搜索条件获取算力总和
     *
     * @return
     */
    @RequestMapping("/v1/report/sumUserCalculateReports")
    public ServiceResponse getSumUserCalculateReports() {
        return reportService.getSumUserCalculateReports(getPageFilter());
    }

    /**
     * 获取资产报表
     *
     * @return
     */
    @RequestMapping("/v1/report/userPropertyReports")
    public ServiceResponse getUserPropertyReports() {
        return reportService.getUserPropertyReports(getPageFilter());
    }

    /**
     * 获取资产总和
     *
     * @return
     */
    @RequestMapping("/v1/report/sumUserPropertyReports")
    public ServiceResponse getSumUserPropertyReports() {
        return reportService.getSumUserPropertyReports(getPageFilter());
    }


    /**
     * 获取用户的任务报表
     *
     * @return
     */
    @RequestMapping("/v1/report/userTaskReports")
    public ServiceResponse getUserTaskReports() {
        return reportService.getUserTaskReports(getPageFilter());
    }

}
